package sword_to_1;

import node.ListNode;

import java.util.ArrayList;
import java.util.List;

public class LeeCode_06 {
    public static void main(String[] args) {

    }
    private static int[] reversePrint(ListNode head) {
        List<Integer> list = new ArrayList<>();
        while (head != null){
            list.add(head.val);
            head = head.next;
        }
        int n = list.size();
        int[] ans = new int[n];
        for(int i = n - 1, j = 0; i >= 0; i--, j++){
            ans[j] = list.get(i);
        }
        return ans;
    }
}
